package neu.dreamera.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import neu.dreamera.R;
import neu.dreamera.utils.FileCacheUtil;
import neu.dreamera.utils.HttpConnectionUtil;

public class TestActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);


        final String url = HttpConnectionUtil.PICTUREURL;

        final Map<String,Object> paramMap = new HashMap<String, Object>();
        paramMap.put("title","test");
        paramMap.put("datetime", "1890-06-08T08:08:00Z");
        paramMap.put("time_str", "my test");
        paramMap.put("place", "120");

        String path = FileCacheUtil.PICTUREPATH + "/6+20160613171354.jpg";
        final File pictureFile = new File(path);

        //开启一个新线程，从服务器端下载JSON数据
        new Thread(){
            public void run(){
                try{
                    HttpConnectionUtil.doPostPicture(url, paramMap, pictureFile);
                } catch(Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();
    }
}
